package com.huanletao.proxy.cglib;

import com.huanletao.proxy.jdkproxy.DefaultLoginServiceImpl;
import com.huanletao.proxy.jdkproxy.LoginService;
import com.huanletao.proxy.jdkproxy.PermissionInterceptor;
import net.sf.cglib.proxy.Enhancer;

/**
 * <p>
 *
 * </p>
 *
 * @package: com.huanletao.proxy.cglib
 * @Description:
 * @className: Main
 * @author: @NNCSKJ ADMIN
 * @copyright: Copyright (c) 2022/6/26 12:43
 * @version: V1.0
 */
public class Main {
    public static void main(String[] args) {
        Enhancer enhancer = new Enhancer();
        // 设置目标类的字节码文件
        enhancer.setSuperclass(DefaultLoginServiceImpl.class);
        // 设置回调函数
        enhancer.setCallback(new PermissionInterceptor());
        // create方法正式创建代理类
        LoginService loginService = (LoginService) enhancer.create();

        loginService.login("admin","123");
    }
}
